package dk.pun.aot.client.widget;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

import dk.pun.aot.client.AnonymousLogin;

public class SplashPanel extends Composite {

	private static SplashPanelUiBinder uiBinder = GWT.create(SplashPanelUiBinder.class);

	interface SplashPanelUiBinder extends UiBinder<Widget, SplashPanel> {}

	@UiField Button signInButton;
	@UiField Button anonymousButton;

	private String signInURL;
	
	public SplashPanel(String signInURL) {
		this.initWidget(uiBinder.createAndBindUi(this));
		this.signInURL = signInURL;
	}
	
	@UiHandler("signInButton")
	public void signInButtonClicked(ClickEvent event) {
		Window.Location.assign(this.signInURL);
	}
	
	@UiHandler("anonymousButton")
	public void anonymousButtonClicked(ClickEvent event) {
		AnonymousLogin.login();
		Window.Location.assign("/");
	}
}
